﻿#!/usr/bin/env python
#-*- coding: utf-8 -*-
  
import logging
import logging.handlers
from logging import *
import os
import datetime

logger = logging.getLogger()
logger.setLevel(logging.DEBUG)

tool_path = os.path.abspath('.')
log_dir_abs_path = u"" + tool_path + "/log"
if not os.path.exists(log_dir_abs_path):
    os.makedirs(log_dir_abs_path)
timestr = datetime.datetime.now().strftime("%Y-%m-%d")
log_file_abspath = log_dir_abs_path + "/" + "log_" + timestr + ".log"
 
rht = logging.handlers.TimedRotatingFileHandler(log_file_abspath, 'D')
fmt = logging.Formatter("%(asctime)s %(filename)s %(funcName)s %(lineno)s \
    %(levelname)s - %(message)s", "%Y-%m-%d %H:%M:%S")
rht.setFormatter(fmt)
logger.addHandler(rht)

debug = logger.debug
info = logger.info
warning = logger.warn
error = logger.error
critical = logger.critical